# This file is part of the Lumenn project 
# at http://code.google.com/p/lumenn/
#
# Released under the GPLv3 at http://www.gnu.org/copyleft/gpl.html
# Designed for pygtk and the Maemo platform.
#
# Copyright 2008 by Jackson Yee (jackson@gotpossum.com)

# *********************************************************************
# indexes: list of tuple pairs
#
# i[0]	Column to sort by
#	i[1]	True for ascending, False for descending
class ListCmp(object):
	def __init__(self, indexes):
		self.indexes = indexes
	
	def __call__(self, v1, v2):
		for i in self.indexes:
			if i[1]:
				if v1[ i[0] ] > v2[ i[0] ]:
					return 1
				elif v1[ i[0] ] < v2[ i[0] ]:
					return -1
			else:
				if v1[ i[0] ] > v2[ i[0] ]:
					return -1
				elif v1[ i[0] ] < v2[ i[0] ]:
					return 1
		
		return 0


